package heima_design.model10;

import java.lang.reflect.Constructor;

/**
 * @ClassName: Test
 * @Description: 反射破坏单例模式
 * @Version: v1.0.0
 * @Author: tang
 * @Date: 2022/06/02
 * Modification History:
 * Date             Author      Version     Description
 * -------------------------------------------------------------
 * 2022/06/02      tang        v1.0.0      创建
 */
public class Test {
	public static void main(String[] args) throws Exception {
		//获取Singleton类的字节码对象
		Class clazz  =  Singleton.class;
		//获取Singleton类的私有无参构造方法对象
		Constructor constructor = clazz.getDeclaredConstructor();
		//取消检查访问
		constructor.setAccessible(true);
		
		//创建Singleton类的对象
		Singleton s1 = (Singleton) constructor.newInstance();
		Singleton s2 = (Singleton) constructor.newInstance();
		
		System.out.println(s1==s2);
	}
}
